package nl.ceasaro.poker.texasHoldEm.game;

import org.apache.commons.lang.builder.ToStringBuilder;

import java.util.HashSet;
import java.util.Set;

/**
 * Created by IntelliJ IDEA.
 * User: cees
 * Date: Apr 20, 2007
 * Time: 10:25:36 PM
 *
 * @todo Document this class
 */
public class TexasTable
{
   private TexasGameManager.Round currentRound = TexasGameManager.Round.POCKET_CARDS;
   HashSet<TexasPlayer> players = new HashSet<TexasPlayer>();
   CommunityCards communityCards = new CommunityCards();

   public void add(TexasPlayer player)
   {
      players.add(player);
   }

   public Set<TexasPlayer> getPlayers()
   {
      return players;
   }

   public CommunityCards getCommunityCards()
   {
      return communityCards;
   }


   public TexasGameManager.Round getCurrentRound()
   {
      return currentRound;
   }

   public void setCurrentRound(TexasGameManager.Round currentRound)
   {
      this.currentRound = currentRound;
   }


   public String toString()
   {
      ToStringBuilder toStringBuilder = new ToStringBuilder(this);
      toStringBuilder.append("currentRound", currentRound).
              append("communityCards", communityCards).
              append("players", players.toArray());
      return toStringBuilder.toString();
   }

   /**
    * reset the communitycards and all players at the table (withdrawing there cards)
    */
   public void reset()
   {
      communityCards.reset();
      for (TexasPlayer texasPlayer : players)
      {
         texasPlayer.reset();
      }
   }
}
